# -*- coding : utf_8 -*-
"""
=======================================
Time : 2025/3/18 10:16
Author : 田霄汉
Email : 522989570@qq.com
File : debug_talk.py
Project : pytest_demo
=======================================
"""
from datetime import datetime, timedelta
import random
import time
from utils.ini_util import IniUtil
from utils.yaml_util import YamlUtil


class DebugTalk:

    # 获取随机数，自定义随机数的范围
    def get_random_number(self, min, max):
        return random.randint(int(min), int(max))

    # 获取随机时间，格式23:59:59
    def get_random_time(self):
        return time.strftime("%H:%M:%S", time.localtime(time.time()))

    # 获取随机日期，格式2014-01-01
    def get_random_date(self):
        start_date = datetime(2010, 1, 1)
        end_date = datetime.now()
        random_date = start_date + timedelta(seconds=random.randint(0, int((end_date - start_date).total_seconds())))
        random_date_str = random_date.strftime('%Y-%m-%d')  # 格式化日期为字符串
        return random_date_str

    # 获取extract.yml里面的关联数据
    def read_extract_yaml(self, key):
        return YamlUtil().read_yaml(yaml_name="../extract.yml", key=key)

    # 获取globalconfig.ini文件里面的配置信息
    def read_global_ini(self, section, key):
        result = IniUtil().read_ini(ini_name="globalconfig.ini", section=section, key=key)
        return result